# -*- coding: iso-8859-2 -*-

import re
import string

from authorshipanalyzer.authorslot import AuthorFiller

class DocumentFeaturesFiller(AuthorFiller):
    '''
    Fill slot with character based features
    '''

    def fill(self, authorslot):
        '''
        Fill a slot
        '''
        lineNumber = 0.0
        blankLineNumber = 0.0
        
        sentenecesFactor = 0.0
        
        for slot in authorslot.slots:
            lines = slot.message.text.split('\n')
            lineNumber += len(lines)

            for line in lines:
                if line.strip() == "":
                    blankLineNumber += 1.0
                    
            sentenecesFactor += slot.dSentences
                    
        authorslot.dBlankLines = blankLineNumber / lineNumber
        authorslot.dSentences = sentenecesFactor / len(authorslot.slots)
        